home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / Imaging & Layout / Scrolling < prev    next >
Encoding:
Text File  |  1995-08-08  |  4.7 KB  |  105 lines  |  [TEXT/ttxt]

  1. OpenDoc™ Recipes
  2.  
  3.  
  4. Scrolling
  5. By The OpenDoc Design Team
  6. 15 July, 1994
  7.  
  8.  
  9. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  10. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  11. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  12.  
  13.  
  14. Coordinate Systems
  15.  
  16. There are two coordinate systems a part can use within a display frame. The frame coordinate space describes where the frame itself is. The content coordinate space describes where the part’s contents within that frame is.
  17.  
  18. By itself, a frame has no way to relate these coordinate spaces to that of any canvas. But a facet on the frame can provide Transform objects that will map coordinates in either the frame or content spaces to the space of the facet’s canvas (or window if needed). (see GetContentTransform, GetFrameTransform)
  19.  
  20. The frame and content coordinate spaces are related by the frame’s internal transform. This transform maps coordinates from the content space into the frame space. A part should change its display frame’s internal transform to scroll its contents. Here’s how that should be done:
  21.  
  22. Simple Scrolling
  23.  
  24. Some parts display only content within their display frames. In this case, the entire area within a frame should scroll. Part handlers must have some way to scroll their content that requires no real estate within the frame - perhaps arrow keys or a “hand cursor” mode.
  25.  
  26. 1) Determine scroll offset (from arrows, cursor motion, etc.)
  27.  
  28. 2) Alter the display frame’s internal transform:
  29.  
  30. xform = displayFrame->AcquireInternalTransform(ev);
  31. xform->MoveBy(ev, scrollOffset);
  32. displayFrame->ChangeInternalTransform(ev, xform);
  33. xform->Release(ev);
  34.  
  35. Note that in the above example, the part may alter the internal transform directly, without having to make a copy of it. This is because the part is the “owner” of the internal transform. However, the part must still use ChangeInternalTransform to let the display frame know that the transform has been changed.
  36.  
  37. Partial Scrolling
  38.  
  39. Some parts display adornments within their display frames that are not part of their scrollable content. The obvious case is a part with scroll bars - the scroll bars should not move when the content in the frame is scrolled. Parts with such frames should keep a content shape which describes which portion of their frame is actually effected by the internal transform. There is no particular place this shape must be stored, as it is internal to the part’s private implementation, but it might be handy to keep it in the partInfo of its frame. As with other shapes, this shape should be in the frame coordinate space.
  40.  
  41. Imaging
  42.  
  43. A part images in a particular facet of one of its display frames, as specified in Part::Draw(). In the simple case, a part will image everything in that frame using the content coordinate transformation. In the case of partial scrolling, the part should image the non-scrolled portion of its frame using the frame coordinate transform, and only the portion of the frame within the content shape should be imaged using the content transform.
  44.  
  45. UI Interaction
  46.  
  47. A part responding to mouse clicks, dragging, or other geometry-based interactions must use the internal transform of its frame to transform the relevant points into the content coordinate space. If a part scrolls everything in the frame, all mouse clicks etc. may be transformed. If the part only scrolls a portion of the frame, it must first hit-test the point with the content shape. Points which fall within the content shape should be transformed by the inverse of the internal transform to convert them into the content coordinate space.
  48.  
  49. Embedding Support
  50.  
  51. A part which scrolls only a portion of its frame needs to take extra care if it embeds other parts. The clip shapes of any embedded facets need to be intersected with the frame’s content shape so that the embedded frames don’t overwrite the non-scrolled portion of the containing frame.
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. The other way
  81.  
  82. The above method is recommended for most cases. There is a second way to implement scrolling that is more resource consumptive and has worse performance, but it may be useful in unusual circumstances.
  83.  
  84. The alternative is to implement the scrollable and non-scrollable portions of the frame as two separate frames. Each frame is a display frame of the same part, but the non-scrolling frame is the containing frame of the scrolling frame. The isSubframe flag of the scrolling frame must be kODTrue for this to work correctly. As usual, there must be a facet for each frame of the part. When the user mouses in the scrollbar in the parent frame, the part changes the internal transform of the child frame. One advantage of this technique is that no special care must be taken to manage the clip shape of any embedded frames.
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.